Skip to content

Conversation

@davidebriani
Copy link

In Node.js 23 and later, dynamically importing a CommonJS module that was transpiled by Babel results in a different module structure than in earlier versions. The structure becomes:

{ __esModule: true, default: { default: [Function] }, 'module.exports': { ... } }

This caused the "arrangeData is not a function" error because the existing dynamicImport() function only handled cases with exactly 2 keys, but Node.js 23+ adds a 'module.exports' key (3 keys total).

Changes:

  • Updated dynamicImport() in utils.js to detect and handle the Node.js 23+ module structure by checking for the presence of module.exports
  • Refactored index.js to apply takeDefaultExport() immediately to both the default and custom data arrangers for consistency

This fix is backward compatible with older Node.js versions and addresses the TypeError that occurred when running spectaql with Node.js v23+.

Fixes #1001.

In Node.js 23 and later, dynamically importing a CommonJS module that
was transpiled by Babel results in a different module structure than in
earlier versions. The structure becomes:
```js
{ __esModule: true, default: { default: [Function] }, 'module.exports': { ... } }
```

This caused the "arrangeData is not a function" error because the
existing dynamicImport() function only handled cases with exactly 2 keys,
but Node.js 23+ adds a 'module.exports' key (3 keys total).

Changes:
- Updated dynamicImport() in utils.js to detect and handle the Node.js 23+
  module structure by checking for the presence of module.exports
- Refactored index.js to apply takeDefaultExport() immediately to both
  the default and custom data arrangers for consistency

This fix is backward compatible with older Node.js versions and
addresses the TypeError that occurred when running spectaql with Node.js
v23+.

Fixes anvilco#1001.

Signed-off-by: Davide Briani <[email protected]>
@paulbehrisch
Copy link

Would be great if we can get that merged please. 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: arrangeData is not a function when using Node v23

2 participants